<select>通过里面的 值或文本 无限加载 <select>
多级联动。
<html> <body> <table> <tr> <td><select id="sel" onchange='e(this)' > <option value="1">aa</option> <option value="2">bb</option> <option value="3">cc</option> <option value="4">d</option> <option value="5">e</option> </select></td> <td><div id="op" >--</div></td> </tr> </table> <input type="text" id="biao" style="width: 250px" > <script type="text/javascript"> function e(a){ var index=a.selectedIndex ; var name = a.options[index].value; alert(name); document.getElementById("biao").value="b1"; var se=" <select id='b1' onchange='ee(this)' >" ; var see=" <option value='1'>11</option> <option value='1'>22</option> <option value='1'>33</option>"; var seee="</select>"; var op =document.getElementById("op"); op.innerHTML = se+see+seee; // //a.outerHTML=""; var s = document.getElementById("sel"); var ops = s.options; alert(ops.length+"size"); for(var i=0;i<ops.length; i++){ var tempValue = ops[i].value; // alert(tempValue); if(tempValue == name) { ops[i].selected = true; } } } function ee(a){ var index=a.selectedIndex ; var name = a.options[index].value; var tx = a.options[index].text ; alert(name); var bb =document.getElementById("biao").value ; var newid = bb+"1" ; var se=" <select id='"+newid+"' onchange='ee(this)' >" ; var see=" <option value='1'>11</option> <option value='1'>22</option> <option value='1'>33</option><option value='1'>44</option><option value='1'>55</option>"; var seee="</select>"; document.getElementById("biao").value = newid ; a.outerHTML = a.outerHTML +se+see+seee; alert("set "+bb +" default" +" this hui is "+tx); var s = document.getElementById(bb); var ops = s.options; alert(ops.length+"size"); for(var i=0;i<ops.length; i++){ var tempValue = ops[i].text; // alert(tempValue); if(tempValue == tx) { ops[i].selected = true; } } s.disabled=true; } </script> </body> </html>
相关标签: